package com.sig;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.sig.formes.Layer;

public class SliderEnabler implements OnClickListener {

	Context context;

	View me;
	ImageView img;
	TextView type;
	Layer l ;

	boolean enabled = true;

	public SliderEnabler(Context context, Layer layer, View v )
	{
		this.context =context;
		me = v;
		this.l = layer;

		loadViews();
		loadData();
		checkListeners();
	}

	private void loadViews() {
		this.type= (TextView) me.findViewById(R.id.layer_enabler_text);
		this.img= (ImageView) me.findViewById(R.id.layer_enabler_image);
	}

	private void loadData() {
		this.type.setText(l.getType());
	}

	private void checkListeners() {
		me.setOnClickListener(this);
	}

	//////////////////////:onClickListener:////////////////////////
	@Override
	public void onClick(View v) {
		Log.v("trt_log","onclick entry");
		switch(v.getId())
		{
		default:
			enabled = !enabled;
			this.l.getParam().setEnable(enabled);

			if(enabled){
				this.type.setTextColor(context.getResources().getColor(R.color.blanc));
			}
			else{
				this.type.setTextColor(context.getResources().getColor(R.color.gris_fonce));
			}
			MainActivity._surfaceView.requestRender();
			break;
		}
	}

}
